package com.yanqu.road.server.cmd.activity.xiuxian;

import com.yanqu.road.entity.activity.xiuxian.config.XiuXianConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.XiuXianProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.xiuxian.CrossXiuXianMgr;
import com.yanqu.road.server.manager.activity.xiuxian.activity.CrossXiuXianActivity;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;


@Cmd(code = CrossProtocol.C_CROSS_XIU_XIAN_LEAVE_SECT_MOUNT, desc = "跨服离开灵峰房间")
public class CrossXiuXianLeaveSectMountCmd extends CrossCommand {

    private int activityId;
    private int mountId;
    private int roomId;
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XiuXianProto.CrossXiuXianLeaveSectMountReqMsg reqMsg = XiuXianProto.CrossXiuXianLeaveSectMountReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        mountId = reqMsg.getMountId();
        roomId = reqMsg.getRoomId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossXiuXianActivity activity = CrossXiuXianMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_XIU_XIAN_ACTIVITY_NOT_FOUND;
            return;
        }
        XiuXianConfig config = activity.getConfig();
        if (config == null) {
            ret = GameErrorCode.E_XIU_XIAN_CONFIG_NOT_FOUND;
            return;
        }
        activity.leaveSectMountByCmd(userId, mountId, roomId);
    }

    @Override
    public void sendData() {
    }
}
